#!/usr/bin/env python
# coding=utf-8
from ConfigParser import ConfigParser

class CapitalAIConfigParser(object):
    def __init__(self):
        from comm import HOME_PATH
        self.conf = HOME_PATH + "/conf/capitalai.ini"
        self._config = ConfigParser()
        self._config.read(self.conf)

    def get(self, section, option, default=""):
        try:
            return self._config.get(section, option)
        except:
            return default

    def get_int(self, section, option, default=-1):
        try:
            return self._config.getint(section, option)
        except:
            return default

    def set(self, section, option, val):
        self._config.set(section, option, val)
        self._config.write(open(self.conf, 'w'))

